package com.qjs.yonth.webService;

import java.io.StringWriter;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.ws.LogicalMessage;
import javax.xml.ws.handler.LogicalHandler;
import javax.xml.ws.handler.LogicalMessageContext;
import javax.xml.ws.handler.MessageContext;

public class loginHandle implements LogicalHandler<LogicalMessageContext>{

	@Override
	public boolean handleMessage(LogicalMessageContext context) {
		boolean outBound = (Boolean)context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
		System.out.println("login"+outBound);
		LogicalMessage message = context.getMessage();
			try {
				Source so=message.getPayload();
				Transformer tran=TransformerFactory.newInstance().newTransformer();
				StringWriter sw=new StringWriter();
	            StreamResult result=new StreamResult(sw);
	            tran.transform(so, result);
	            System.out.println(sw.toString());
			} catch (Exception e) {
				System.out.println("loginHandle");
				e.printStackTrace();
			}
	
		
		return true;
	}

	@Override
	public boolean handleFault(LogicalMessageContext context) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void close(MessageContext context) {
		// TODO Auto-generated method stub
		
	}

}
